SAS programs and data

These programs demonstrate estimation of some of the models discussed in the book and the supplementary teaching note Gibbs Estimation of Microstructure Models.

SAS programs v0100 is a zipped file of the programs, listings and data.

Conventions and usage

The programs (listed below) call various SAS macro routines that are supplied in the directory 'SAS Macros'.

To run the programs, you'll need to edit a directory pointer. The first line of each program is usually:

x 'cd c:\Active\EMM Distribution\SAS Programs v0100';

Modify this statement to point to the location where you've unzipped the files. E.g.,

x 'cd c:\MyEMM';

The programs reference two other locations ('SASData' and 'SAS Macros') but these are defined relative to the starting directory, and should not require additional modification.

Some of the programs produce pdf listing files. If you'd like output to go to the usual destination, remove the two ODS statements (at the beginning and end of each program).

 

Program Name

Description

Generalized Roll 02.sas

Simulate and estimate the generalized Roll model discussed in Chapter 8. Demonstrates computation of random-walk variance and lower bound for pricing error variance.

The key SAS routines are proc arima (to estimate the basic time series model) and proc iml (to compute the variances). The code for both is in the GRUnivariate macro.

Generalized Roll 03.sas

Estimate the generalized Roll model on sample of real data (Matritech stock, ticker symbol MZT, October, 2005).

Simple Multivariate 02.sas

Simulate and estimate the model of trades and quotes discussed in Chapter 9; variance decomposition of trades and quotes. Demonstrates use of alternative causal permutations (trades followed by prices / prices followed by trades) in computing variance decompositions.

The key SAS routines are proc varmax (to estimate the VAR) and proc iml (to compute the variance decomposition, in the VarianceDecomp macro).

VAR Price and Trade 01.sas

Estimate a bivariate vector autoregression (VAR) on a sample of real price and trade data (MZT); variance decomposition.

VECM 01.sas

Simulate and estimate the vector error correction model (VECM) for the model discussed in section 10.2; price discovery via variance decomposition.

Proc varmax is used to compute the VECM; the variance decomposition is done in proc iml (using the VarianceDecomp macro).

VECM 02.sas

VECM and variance decomposition for a sample of real data. NYSE and Pacific (Arca) quotes for MZT.

The qBuild macro constructs a parallel record of quotes from the various trading venues. The record is constructed in clock time, but at a user-specified frequency.

The VECM is estimated using proc model. Proc varmax (used in VECM 01.sas, above) is a competent program, but it can't handle prespecified cointegration vectors, missing data, etc.. Proc model is much more flexible in these respects.

The VarianceDecomp macro is used to compute the random-walk variance decompositions.

RollGibbs 2-trade case.sas Gibbs simulation of trade direction variables.
RollGibbs Analyze q.sas Estimate and analyze simulated trade directions.
RollGibbs 01.sas Full Gibbs estimation of the basic Roll model.
RollGibbsBeta 01.sas Full Gibbs estimation of the Roll model including a market factor.
RollGibbs Library 01.sas Compile subroutines needed for Gibbs estimation.